package com.app.piemoment.entity;

import java.util.List;

import android.content.Context;
import android.graphics.Color;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ListAdapter;
import android.widget.TextView;

import com.app.piemoment.R;

public class GridAdapter extends BaseAdapter implements ListAdapter {

	private Context mContext;
	public static int DEFAULT_NUM = 8;
	private List<String> gridItem = null;
	private TextView[] tView;
	private String stringLight;

	public String getStringLight() {
		return stringLight;
	}

	public void setStringLight(String stringLight) {
		this.stringLight = stringLight;
	}

	public GridAdapter(Context c) {
		mContext = c;
	}

	public void setGridItem(List<String> gridItem, String stringLight) {
		this.gridItem = gridItem;
		this.stringLight = stringLight;
		createTView();
	}

	public void createTView() {
		tView = new TextView[getCount()];
		for (int x = 0; x < getCount(); x++) {
			tView[x] = new TextView(mContext);
			tView[x].setGravity(Gravity.CENTER);
			tView[x].setSingleLine();
			tView[x].setTextAppearance(mContext,
					android.R.style.TextAppearance_Large);
			if (null != stringLight && stringLight.length() > 0
					&& gridItem.get(x).equals(stringLight)) {
				tView[x].setTextColor(Color.YELLOW);
			}
			tView[x].setBackgroundColor(R.color.grey);
			tView[x].setText(gridItem.get(x));
		}
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return gridItem.size();
	}

	@Override
	public Object getItem(int arg0) {
		// TODO Auto-generated method stub
		return tView[arg0];
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		return tView[position];
	}

	public void setLight(String string) {

	}
}
